import { API_LIST } from '../../../Api/Api'
import { commonTableList, BuiltInData } from '../Common/common'
import { OpenExcelButton, SelectExcelButton } from '../Common/options'

const independenceList = {
    'jtgjadmin.ljkjkf.com': 'organizationUuid',
    'jtgjadmin.hljsjtgj.com': 'organizationUuid',
}

export const PersonA02 = async ({ url, OptionsEvent, ClientData, Permission, actionRef }) => {
    const { hostname } = window.location
    Permission = Permission?.find(v => v.targetUrl === url).children
    let data = {
        pageSize: 10,
        params: { pageIndex: 1 },
        independenceSet: {
            title: '组织机构',
            url: 'getOrgTree',
            data: { IsByUserUuid: 1 },
            type: 'TableNavTree001',
            all: true,
        },
        independence: independenceList[hostname],
        get: API_LIST()[`getPersonEntryLeavesOC`],
        options: [
            <OpenExcelButton
                key="one"
                title="导入进退场信息"
                OptionsEvent={OptionsEvent}
                type="primary"
                data={{
                    save: true,
                    submit: true,
                    url: 'getPersonEntryLeavesTemplate',
                    pos: 'posPersonEntryLeavesBatchImport',
                }}
            />,
            <SelectExcelButton
                key="excel"
                title="导出进退场信息"
                OptionsEvent={OptionsEvent}
                api={API_LIST()['posPersonRosterExcel']}
                data={{ independenceActive: true }}
            />,
        ],
        columns: [
            commonTableList.uuid,
            { ...commonTableList.organizationUuid, valueEnum: ClientData.organization, title: '单位' },
            {
                dataIndex: ['person', 'tableName'],
                title: '姓名',
                valueType: 'input',
                ellipsis: true,
                rules: true,
                width: 200,
            },
            {
                dataIndex: ['person', 'gender'],
                title: '性别',
                valueType: 'select',
                valueEnum: BuiltInData.gender,
                ellipsis: true,
                rules: true,
                width: 200,
            },
            {
                dataIndex: ['person', 'age'],
                title: '年龄',
                valueType: 'input',
                ellipsis: true,
                rules: true,
                width: 200,
            },
            {
                dataIndex: ['person', 'workType'],
                title: '工种',
                valueType: 'input',
                ellipsis: true,
                rules: true,
                width: 200,
            },
            {
                dataIndex: 'entryTime',
                title: '进场时间',
                valueType: 'input',
                ellipsis: true,
                rules: true,
                width: 200,
            },
            {
                dataIndex: 'leaveTime',
                title: '离场时间',
                valueType: 'input',
                ellipsis: true,
                rules: true,
                width: 200,
            },
            {
                dataIndex: ['person', 'address'],
                title: '籍贯',
                valueType: 'input',
                ellipsis: true,
                rules: true,
                width: 200,
            },
            {
                dataIndex: ['person', 'idCard'],
                title: '身份证',
                valueType: 'input',
                ellipsis: true,
                rules: true,
                width: 200,
            },
            {
                dataIndex: ['person', 'mobile'],
                title: '联系电话',
                valueType: 'input',
                ellipsis: true,
                rules: true,
                width: 200,
            },
            {
                dataIndex: 'remark',
                title: '备注',
                valueType: 'input',
                ellipsis: true,
                rules: true,
                width: 200,
            },
        ],
    }
    return data
}
